package com.henry.others;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Scanner;

public class SlightlyVaryingNumbersTest {
    public static void main(String [] args) {
        Scanner keyboard = new Scanner(System.in);

        System.out.println("Please input num and maxDiff: ");
        int count = keyboard.nextInt();
        int maxDiff = keyboard.nextInt();
        int breakPoint = -1;

        System.out.println("Please input " + count + " numbers: ");
        int[] numArray = new int[count];
        numArray[0] = keyboard.nextInt();
        int previousNum = numArray[0];
        for (int i = 1; i < count; ++i) {
            numArray[i] = keyboard.nextInt();
            if (breakPoint == -1 && Math.abs(numArray[i] - previousNum) > maxDiff) breakPoint = i;
            previousNum = numArray[i];
        }

        System.out.println("Numbers input are: ");
        for (int num : numArray) {
            System.out.print(num + " ");
        }
        System.out.print("\n");
        if (breakPoint != -1) System.out.println("The array break at the #" + breakPoint + " number.");
        else System.out.println("This array contains " + count + " numbers. They are varying slightly.");
    }
}

